package homework;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

@WebServlet(urlPatterns="/doReg1.action")
public class Servlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");

        PrintWriter out=response.getWriter();
        String name=request.getParameter("username");
        String passWord=request.getParameter("psd");
        String gender=request.getParameter("sex");
        String[] hobbys=request.getParameterValues("hobby");
        String province=request.getParameter("province");
        String resume=request.getParameter("resume");

        request.setAttribute("username",name);
        request.setAttribute("psd",passWord);
        request.setAttribute("sex",gender);
        request.setAttribute("hobby",hobbys);
        request.setAttribute("province",province);
        request.setAttribute("resume",resume);

        request.getRequestDispatcher("/regInfo.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}
